﻿/* **
 * WebQ - a Web Questionare / Survey Framework
 * Andrew Adhi Ariane Murniadi / 2009
 * GPL
 * $Id$
 *									** */

using System;
using System.Collections.Generic;
using System.Text;
using WebQ.Visualizers;

namespace WebQ.Core {
	/// <summary>
	/// Types of available Visualizer
	/// </summary>
	public enum WebQVisualizerType {
		TextBox,
		CheckBox,
		RadioBox,
		Essay,
	}

	/// <summary>
	/// Configuration for Visualizer use when creating Controls
	/// </summary>
	public class WebQVisualizerConfiguration {
		private Boolean m_zRequired = false;
		private List<String> m_options = new List<String> ();
		private WebQVisualizerType m_visualizerType = WebQVisualizerType.TextBox;

		/// <summary>
		/// Whether the question is required or not
		/// </summary>
		public Boolean IsRequired {
			get { return m_zRequired; }
			set { m_zRequired = value; }
		}

		/// <summary>
		/// List of answer options to select from
		/// </summary>
		public List<String> Options {
			get { return m_options; }
		}

		/// <summary>
		/// Returns the visualizer selected
		/// </summary>
		public WebQVisualizer Visualizer {
			get { return CreateVisualizer (); }
		}

		/// <summary>
		/// Returns the type of the visualizer
		/// </summary>
		public WebQVisualizerType VisualizerType {
			get { return m_visualizerType; }
			set { m_visualizerType = value; }
		}

		/// <summary>
		/// Creates the specified visualizer
		/// </summary>
		/// <returns>created visualizer</returns>
		private WebQVisualizer CreateVisualizer () {
			switch ( m_visualizerType ) {
				case WebQVisualizerType.TextBox:
				default: // for now always create text box
					return new WebQTextBoxVisualizer ( new WebQIdGenerator (), this );
			}
		}
	}
}
